/*
 *  debug.c
 *
 *  MyQQ debugger.
 *
 *  Copyright (C) 2008  Huang Guan
 *
 *  2008-01-31 Created.
 *
 */

#include <stdio.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#ifdef _WINDOWS
#include <io.h>
#endif
#include <time.h>
#include "debug.hpp"
#include "util.hpp"
#include "qqdef.hpp"
#include "utf8.hpp"
#include <QDebug>
#include <QString>
static int dbg_term = 0, dbg_file = 0, log_day = 0;

static char dir[128]={0,}, filename[160];
static void init_file_path();

void print_error_qs(const char* file,const char* function, int line, const QString fmt)
{
	qDebug()<<QObject::tr(file)<<"("<<line<<"): "<<fmt;	
}
void print_error(const char* file, const char* function, int line, const char *fmt, ...)
{
	va_list args;
	QString qs;
	int i;
	va_start(args, fmt);
	qs.vsprintf(fmt,args);	
	va_end(args);
	qDebug()<<QObject::tr(file)<<"("<<line<<"): "<<qs;	
}

static char* hex_str(unsigned char *buf, int len, char* outstr )
{

	const char *set = "0123456789abcdef";
	char *tmp;
	unsigned char *end;
	if (len > 1024)
	len = 1024;
	end = buf + len;
	tmp = &outstr[0];
	while (buf < end)
	{
          *tmp++ = set[ (*buf) >> 4 ];
          *tmp++ = set[ (*buf) & 0xF ];
          *tmp++ = ' ';
          buf ++;
	}
	*tmp = '\0';
	return outstr;
}

void hex_dump( unsigned char * buf, int len )
{
	//TODO:
}


